package TestConcurrent;

import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-04-18
 * Time: 11:45
 */
public class DemoSemaphore {
    public static void main(String[] args) throws InterruptedException {
        //停车场显示牌
        //初始化可用资源 4个
        Semaphore semaphore = new Semaphore(4);
        //申请资源,P操作
        semaphore.acquire(2);
        //释放资源,V操作
        semaphore.release(2);
    }
}
